package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrdersMapper {

    /**
     * 添加订单
     * @param orders
     * @return
     */
    @Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values (#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")
    @Options(useGeneratedKeys = true,keyProperty = "orderId",keyColumn = "orderId")
    public int saveOrders(Orders orders);

    /**
     * 根据orderId查询订单信息
     * @param orderId
     * @return
     */
//    @Select("select * from orders where orderId = #{orderId}")
    public Orders getOrdersById(Integer orderId);


    /**
     * 根据userId查询到所有订单信息
     * @param userId
     * @return
     */
//    @Select("select * from orders where userId = #{userId}")
    public List<Orders> listOrderByUserId(String userId);

}
